﻿//using System;
//using System.Text;
//using System.Collections.Generic;
//using System.Linq;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Microsoft.WindowsAzure;
//using System.Configuration;
//using AzureGames.Repository.Interfaces;
//using Microsoft.WindowsAzure.StorageClient;
//using Moq;
//using AzureGames.Repository;
//using AzureGames.Repository.TableServiceEntities;

//namespace AzureGames.Data.Implementation.Tests
//{
//    [TestClass]
//    public class GameDefinitionTests
//    {
//        public GameDefinitionTests()
//        {
        
//        }
//        [TestMethod]
//        public void GetGameDefinitions_CallsGetGameDefOnce()
//        {
//            //Arrange
//            var mockGameDef = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameResource = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameProperty = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            GameDefinitionRepository rep = new GameDefinitionRepository(mockGameDef.Object, mockGameResource.Object, mockGameProperty.Object);
            
//            //Act
//            var result = rep.GetGameDefinitions();
           
//            //Assert
//            mockGameDef.Verify(n => n.Get("GameDefinition"), Times.Once());
//        }

//        [TestMethod]
//        public void GetGameDefinitions_ReturnsCorrectNumberOfGameDefs()
//        {
//            //Arrange
//            var mockGameDef = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameResource = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameProperty = new Mock<IAzureTableRepository<TableServiceEntity>>();

//            var gameList = new List<TableServiceEntity>() {
//                { new GameDefinitionEntity { ID = 1, Description = "id1", Instructions = "inst"}},
//                { new GameDefinitionEntity { ID = 1, Description = "id1", Instructions = "inst"}}
//            };

//            mockGameDef.Setup(n => n.Get("GameDefinition")).
//                Returns(gameList);

//            GameDefinitionRepository rep = new GameDefinitionRepository(mockGameDef.Object, mockGameResource.Object, mockGameProperty.Object);

//            //Act
//            var result = rep.GetGameDefinitions();

//            //Assert
//            Assert.IsTrue(result.Count() == 2);
//        }

//        [TestMethod]
//        public void GetGameDefinitions_ReturnsEmptyListIfNoGameDefsFound()
//        {
//            //Arrange
//            var mockGameDef = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameResource = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameProperty = new Mock<IAzureTableRepository<TableServiceEntity>>();

           

//            mockGameDef.Setup(n => n.Get("GameDefinition")).
//                Returns<List<TableServiceEntity>>(null);

//            GameDefinitionRepository rep = new GameDefinitionRepository(mockGameDef.Object, mockGameResource.Object, mockGameProperty.Object);

//            //Act
//            var result = rep.GetGameDefinitions();

//            //Assert
//            Assert.IsTrue(result.Count() == 0);
//        }

//        [TestMethod]
//        public void GetGameDefinitions_ReturnsJavascriptResourcesJavascriptListWhenRepReturnsSome()
//        {
//            //Arrange
//            var mockGameDef = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameResource = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameProperty = new Mock<IAzureTableRepository<TableServiceEntity>>();

//            int gameID = 1;
//            var gameDef = new GameDefinitionEntity { ID = gameID, Description = "id1", Instructions = "inst" };

//            mockGameDef.Setup(n => n.Get("GameDefinition", gameID.ToString())).
//                Returns(gameDef);

//            Guid guid1 = Guid.NewGuid();
//            Guid guid2 = Guid.NewGuid();
//            Guid guid3 = Guid.NewGuid();

//            var js = new List<TableServiceEntity>() {
//                { new GameResourceEntity { ID = Guid.NewGuid(), RowKey = guid1.ToString(), ResourceOrder = 1}},
//                { new GameResourceEntity { ID = Guid.NewGuid(), RowKey = guid2.ToString(), ResourceOrder = 2}},
//                { new GameResourceEntity { ID = Guid.NewGuid(), RowKey = guid3.ToString(), ResourceOrder = 3}}
                
//            };


//            mockGameResource.Setup(n => n.GetListByNamedProperty("JavascriptFile", "GameID", 1)).
//                Returns(js);

//            GameDefinitionRepository rep = new GameDefinitionRepository(mockGameDef.Object, mockGameResource.Object, mockGameProperty.Object);

//            //Act
//            var result = rep.GetGameDefinition(1);

//            //Assert
//            Assert.IsTrue(result.JavascriptFiles.Count == 3);
//            Assert.IsTrue(result.JavascriptFiles.Contains(guid1));
//            Assert.IsTrue(result.JavascriptFiles.Contains(guid2));
//            Assert.IsTrue(result.JavascriptFiles.Contains(guid3));
//        }

//        [TestMethod]
//        public void GetGameDefinitions_ReturnsCssResourcesCssListWhenRepReturnsSome()
//        {
//            //Arrange
//            var mockGameDef = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameResource = new Mock<IAzureTableRepository<TableServiceEntity>>();
//            var mockGameProperty = new Mock<IAzureTableRepository<TableServiceEntity>>();

//            int gameID = 1;
//            var gameDef = new GameDefinitionEntity { ID = gameID, Description = "id1", Instructions = "inst" };

//            mockGameDef.Setup(n => n.Get("GameDefinition", gameID.ToString())).
//                Returns(gameDef);

//            Guid guid1 = Guid.NewGuid();
//            Guid guid2 = Guid.NewGuid();
//            Guid guid3 = Guid.NewGuid();

//            var js = new List<TableServiceEntity>() {
//                { new GameResourceEntity { ID = Guid.NewGuid(), RowKey = guid1.ToString(), ResourceOrder = 1}},
//                { new GameResourceEntity { ID = Guid.NewGuid(), RowKey = guid2.ToString(), ResourceOrder = 2}},
//                { new GameResourceEntity { ID = Guid.NewGuid(), RowKey = guid3.ToString(), ResourceOrder = 3}}
                
//            };


//            mockGameResource.Setup(n => n.GetListByNamedProperty("CSSFile", "GameID", 1)).
//                Returns(js);

//            GameDefinitionRepository rep = new GameDefinitionRepository(mockGameDef.Object, mockGameResource.Object, mockGameProperty.Object);

//            //Act
//            var result = rep.GetGameDefinition(1);

//            //Assert
//            Assert.IsTrue(result.CSSFiles.Count == 3);
           
//        }
//    }
//}
